﻿using System;
using Csla.Xaml;
using HeThongThongTin.Library;
using System.ComponentModel;
using Utility;
using HeThongThongTin.Library.Utility;

namespace HeThongThongTin.UI.SL.TiepNhanHoSo.TNHS_HoSoTiepNhan
{
    public class TNHS_HoSoTiepNhan_ViewModel : ViewModel<HeThongThongTin.Library.TNHS_HoSoTiepNhan>
    {
        #region Event Declare
        public delegate void ChildList_AddedNew_EventHandler(object sender, ChildListAddedNewArgs e);

        public delegate void LoaiNghiepVu_EventHandler(object sender, LoaiNghiepVuEventArgs e);
      
        public event ChildList_AddedNew_EventHandler ChildList_AddedNew;
        public event LoaiNghiepVu_EventHandler LoaiNghiepVuChanged;
        public event EventHandler LoaiHoSoChanged;

        #endregion

        #region Refresh Model
        public TNHS_HoSoTiepNhan_ViewModel()
        {
            BeginRefresh("NewTNHS_HoSoTiepNhan");
            
        }

        public TNHS_HoSoTiepNhan_ViewModel(int Khoa)
        {
            BeginRefresh("GetTNHS_HoSoTiepNhan", Khoa);
           
        }

        public void NewTNHS_HoSoTiepNhanViewModel()
        {
            BeginRefresh("NewTNHS_HoSoTiepNhan");
            
        }

        public void GetTNHS_HoSoTiepNhanViewModel(int Khoa)
        {
            BeginRefresh("GetTNHS_HoSoTiepNhan", Khoa);
        }

       
        public void SaveAndNew()
        {
            BeginSave();
            NewTNHS_HoSoTiepNhanViewModel();
        }
        protected override void OnRefreshed()
        {
            base.OnRefreshed();
            if (Model != null)
            {
                Model.TNHS_HoSoTiepNhan_GiayToKemTheos.AddedNew += new EventHandler<Csla.Core.AddedNewEventArgs<TNHS_HoSoTiepNhan_GiayToKemTheoChild>>(TNHS_HoSoTiepNhan_GiayToKemTheos_AddedNew);
                Model.LoaiNghiepVuChanged += new EventHandler<LoaiNghiepVuEventArgs>(OnLoaiNghiepVuChanged);
                Model.LoaiHoSoChanged += new EventHandler(OnLoaiHoSoChanged);
            }
        }
        #endregion
        
        #region Add TNHS_HoSoTiepNhan Details Item
        public void AddTNHS_HoSoTiepNhan_GiayToKemTheoItem()
        {
            Model.TNHS_HoSoTiepNhan_GiayToKemTheos.AddNewItem(Model.Khoa);
        }

        void TNHS_HoSoTiepNhan_GiayToKemTheos_AddedNew(object sender, Csla.Core.AddedNewEventArgs<TNHS_HoSoTiepNhan_GiayToKemTheoChild> e)
        {
            OnChildList_AddedNew(sender, new ChildListAddedNewArgs("TNHS_HoSoTiepNhan_GiayToKemTheos"));
        }



        protected virtual void OnLoaiNghiepVuChanged(object sender, LoaiNghiepVuEventArgs e)
        {
            if (LoaiNghiepVuChanged != null)
            {
                LoaiNghiepVuChanged(sender, e);
            }
        }
        protected virtual void OnLoaiHoSoChanged(object sender, EventArgs e)
        {
            if (LoaiHoSoChanged != null)
            {
                LoaiHoSoChanged(sender, e);
            }
        }
       

        protected virtual void OnChildList_AddedNew(object sender, ChildListAddedNewArgs e)
        {
            if (ChildList_AddedNew != null)
            {
                //Invokes the delegates.
                ChildList_AddedNew(sender, e);
            }
        }

      
       
       
        #endregion

        #region Delete TNHS_HoSoTiepNhan Details Item

        public void DeleteTNHS_HoSoTiepNhan_GiayToKemTheoItem(int Index)
        {
            Model.TNHS_HoSoTiepNhan_GiayToKemTheos.DeleteItem(Index);
        }
        
        
        #endregion

        
    }
}
